<?php

namespace App\Api\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Route;

class UserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $route = Route::currentRouteName();

        switch ($route) {
            case 'auth.verifyCode':
                return [
                    'code' => 'required',
                ];
                break;
            default:
                return [];
        }
    }

    public function attributes()
    {
        return [
            'code'     => '临时登录凭证',
            'nickname' => '用户昵称',
            'avatar'   => '头像',
            'gender'   => '用户性别',
            'country'  => '用户所在国家',
            'province' => '用户所在省份',
            'city'     => '用户所在城市',
            'language' => '所用的语言',
        ];
    }
}
